﻿

using Net13_Others;

TestClass();
TestStructs();

void TestClass()
{
    Animal animal = new Animal { Name = "animal" };
    Animal cat = new Cat { Name = "tom" };
    Animal dog = new Dog { Name = "happa" };
    Dog dog2 = (Dog)dog;

    animal.Run();
    cat.Run();
    dog.Run();
    dog2.Run();
    /*
     *
    animal running...
    cat running...
    animal running...
    dog running...
     */

    HappaDog dog3 = new HappaDog { Name = "hap" };
    dog3.Hi();
    dog3.HelloDog();
    /*
    This is Happa hello dog
    hello dog
     */
}

void TestStructs()
{
    Point p;
    p.X = 1;
    p.Y = 2;
    Console.WriteLine(p);

    var p2 = new Point { X = 2, Y = 3 };
    Console.WriteLine(p2);
    /*
x: 1, y: 2
x: 2, y: 3
     *
     */
    //Point p3;
    //Console.WriteLine(p3); // 定义了构造函数后，必须给成员变量赋值，或使用new，否则失败
    var p4 = new Point();
    Console.WriteLine(p4);
}